package com.malljelly.study.producer;

import com.malljelly.study.config.ProducerConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 消息生产者
 */
@Slf4j
@Component
public class MessageProducerService {


    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * 发送的交换器,投放的key 投放的消息
     * @param msgJson
     */
    public void sendMessage(String msgJson) {
        this.rabbitTemplate.convertAndSend(ProducerConfig.EXCHANGE,
                ProducerConfig.ROUTINGKEY, msgJson);
    }
}
